/**
 * 
 */
package ihm;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;

import org.janusproject.kernel.address.AgentAddress;

import sma.agents.bodies.CircleBody;
import sma.agents.listeners.DeleteListener;
import sma.agents.listeners.MoveListener;

import appli.utils.Config;

/**
 * @author sainton
 *
 */
public class VehicleLayered extends JLayeredPane {
	
	/**
	 * Le panel qui contient la voiture :
	 */
	private MassCenterPanel massCenterPanel;
	
	/**
	 * Telemeter panels to display
	 */
	private List<TelemetrePanel> telePanels = new ArrayList<TelemetrePanel>();
	

	private int height;
	/**
	 * @param height La hauteur du panel (la largeur est fixée)
	 */
	public VehicleLayered(int height) {
				
		this.massCenterPanel = new MassCenterPanel(height, telePanels);
		this.height = height;
		
		this.setPreferredSize(new Dimension(Config.PANEL_SIZE * 2, height));
		
		//Draw windows
		this.setOpaque(true);
	    this.setForeground(Color.blue);
	    this.setBorder(BorderFactory.createLineBorder(Color.red));
	    this.setBounds(0 ,0 , Config.PANEL_SIZE * 2, height);
	    
	    
	}
	
	/**
	 * 
	 * @return massCenterPanel
	 */
	public MassCenterPanel getMassCenterPanel() {
		return massCenterPanel;
	}
	
	/**
	 * Add a telemeterPanel
	 * @param panel le panel du télémètre
	 */
	public void addTelemeterPanel(TelemetrePanel panel){
		int nbPanel = telePanels.size();
		panel.setBounds(0, nbPanel * (Config.PANEL_SIZE + 140), Config.PANEL_SIZE * 2, Config.PANEL_SIZE );
		telePanels.add(panel);
	}

	/**
	 * Build the vehicleLayered :
	 * add telemeterPanel and the massCenterPanel
	 */
	public void build() {
		this.add(telePanels.get(0),0);
		this.add(telePanels.get(1),1);
	
		this.add(massCenterPanel, new Integer(2), 0);
		this.moveToFront(massCenterPanel);
		
		this.repaint();
	}
}
